package org.sunyaxing.transflow.transflowapp.factory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.sunyaxing.transflow.api.extensions.base.ExtensionContext;

import java.lang.reflect.Constructor;

@Service
public class TransFlowExtensionFactory {
    private static final Logger log = LoggerFactory.getLogger(TransFlowExtensionFactory.class);

    public <T> T create(ExtensionContext extensionContext, Class<T> extensionClass) {
        try {
            Constructor<T> constructor = extensionClass.getConstructor(ExtensionContext.class);
            return constructor.newInstance(extensionContext);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
